home *** CD-ROM | disk | FTP | other *** search
/ Die Ultimative Software-P…i Collection 1996 & 1997 / Die Ultimative Software-Pakete CD-ROM fur Atari Collection 1996 & 1997.iso / g / gnu_c / gempp19.zoo / gem++19 / src / gemfn.cc < prev    next >
Encoding:
C/C++ Source or Header  |  1993-11-16  |  1.8 KB  |  129 lines

  1. #include "vdi.h"
  2. #include "gemfn.h"
  3. #include "gemfl.h"
  4. #include <vdibind.h>
  5.  
  6. static const int ARBSIZE=0x80;
  7.  
  8. GEMfont::GEMfont(VDI& v, int cde, int sz) :
  9.     vdi(v),
  10.     code(cde),
  11.     size(sz),
  12.     flags(0)
  13. {
  14.     GEMfontlist list(vdi);
  15.     if (list.ArbitrarilySizable(list.IndexOfFontCoded(code))) {
  16.         flags|=ARBSIZE;
  17.     } else {
  18.         flags&=~ARBSIZE;
  19.     }
  20. }
  21.  
  22. GEMfont::GEMfont(VDI& v, const GEMfont& font) :
  23.     vdi(v),
  24.     code(font.code),
  25.     size(font.size),
  26.     flags(font.flags)
  27. {
  28. }
  29.  
  30. GEMfont::GEMfont(VDI& v) :
  31.     vdi(v)
  32. {
  33.     int attrib[10];
  34.  
  35.     vdi.qt_attributes(attrib);
  36.  
  37.     code=attrib[0];
  38.     size=attrib[7];
  39. }
  40.  
  41. int GEMfont::Code() const
  42. {
  43.     return code;
  44. }
  45.  
  46. void GEMfont::Code(int i)
  47. {
  48.     code=i;
  49.     GEMfontlist list(vdi);
  50.     if (list.ArbitrarilySizable(list.IndexOfFontCoded(code))) {
  51.         flags|=ARBSIZE;
  52.     } else {
  53.         flags&=~ARBSIZE;
  54.     }
  55. }
  56.  
  57. char* GEMfont::Name() const
  58. {
  59.     GEMfontlist list(vdi);
  60.     return list.FontName(list.IndexOfFontCoded(code));
  61. }
  62.  
  63. int GEMfont::PointSize() const
  64. {
  65.     return size;
  66. }
  67.  
  68. void GEMfont::PointSize(int sz)
  69. {
  70.     size=sz;
  71. }
  72.  
  73. bool GEMfont::ArbitrarilySizable() const
  74. {
  75.     return (flags&ARBSIZE)!=0;
  76. }
  77.  
  78. bool GEMfont::Larger()
  79. {
  80.     GEMfont originalfont(vdi);
  81.  
  82.     int prevsize=size;
  83.     int trysize=size+1;
  84.  
  85.     while (prevsize==size && trysize<=size*4) {
  86.         int j;
  87.         size=vdi.st_point(trysize,&j,&j,&j,&j);
  88.         trysize++;
  89.     }
  90.  
  91.     originalfont.Use();
  92.  
  93.     return prevsize!=size;
  94. }
  95.  
  96. bool GEMfont::Smaller()
  97. {
  98.     GEMfont originalfont(vdi);
  99.  
  100.     int prevsize=size;
  101.     int trysize=size-1;
  102.  
  103.     while (prevsize==size && trysize>0) {
  104.         int j;
  105.         size=vdi.st_point(trysize,&j,&j,&j,&j);
  106.         trysize--;
  107.     }
  108.  
  109.     originalfont.Use();
  110.  
  111.     return prevsize!=size;
  112. }
  113.  
  114. void GEMfont::Use() const
  115. {
  116.     vdi.st_font(code);
  117.  
  118.     // XXX At present, this information is not retained.
  119.     int actualheight;
  120.     int cw,ch,bw,bh;
  121.  
  122.     if (ArbitrarilySizable()) {
  123.         actualheight=vdi.st_arbpt(size,&cw,&ch,&bw,&bh);
  124.     } else {
  125.         actualheight=vdi.st_point(size,&cw,&ch,&bw,&bh);
  126.     }
  127. }
  128.  
  129.